package adv7;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.*;

public class ObjectThread extends Thread {
	private Socket s;
	private List<String> list = new ArrayList<>();

	public ObjectThread(Socket s) {
		this.s = s;
		list.add("阿猫");
		list.add("阿狗");
		list.add("熊猫");
	}

	@Override
	public void run() {
		try {
			// InputStream in = s.getInputStream();
			OutputStream out = s.getOutputStream();
			ObjectOutputStream oout = new ObjectOutputStream(out);
			oout.writeObject(list);
			oout.flush();
			System.out.println("对象发送" + s + " 完成");
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				s.close();
			} catch (Exception e) {
				// TODO 自动生成的 catch 块
				// e.printStackTrace();
			}
		}

	}
}
